﻿using Houtel.IDal;
using Microsoft.EntityFrameworkCore;
using System.Linq.Expressions;

namespace Houtel.Dal
{
    public class BaseDal<T> : IBaseDal<T> where T : class
    {
        private readonly HoutelDbContext db;

        public BaseDal(HoutelDbContext db)
        {
            this.db = db;
        }
        public IQueryable<T> GetList()
        {
            return db.Set<T>().AsQueryable();
        }

        public async Task<T> GetValue(Expression<Func<T, bool>> exp)
        {
            return await db.Set<T>().Where(exp).FirstOrDefaultAsync();
        }
    }
}
